﻿namespace HanLuoTower
{
    class Program
    {
        static void Main(string[] args)
        {
            //输入移动盘子的个数
            Console.WriteLine("请输入盘子的数量");
            int Number = Convert.ToInt32(Console.ReadLine());
            //用A,B,C分别代表三个柱子
            char position1 = 'A', position2 = 'B', position3 = 'C';
            HanLuoMove(Number, position1, position2, position3);
        }
        //起始柱、中间柱、目标柱
        static void HanLuoMove(int Number, char position1, char position2, char position3)
        {
            //如果只有一个盘子，则直接将其移动到C柱子
            if (Number == 1)
                Console.WriteLine($"将第{Number}个盘从{position1}柱移动到{position3}柱");
            else
            {  //将n-1个盘经position3移动到position2
                HanLuoMove(Number - 1, position1, position3, position2);
                //将最后一个盘移动到C柱
                Console.WriteLine($"将第{Number}个盘从{position1}柱移动到{position3}柱");
                //递归:将n-1个盘经position1移动到position3
                HanLuoMove(Number - 1, position2, position1, position3);
            }
        }
    }
}
